package com.zhen.concurrent.chapter04;

import java.util.concurrent.TimeUnit;

public class Mutex {

    private static final Object MUTEX = new Object();

    private void accessResource(){
        synchronized(MUTEX){
            try{
                TimeUnit.MINUTES.sleep(10);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        final Mutex mutex = new Mutex();
        for(int i = 0 ; 0 < 5 ; i++){
            new Thread(mutex::accessResource).start();
        }
    }
}
